<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/9
 * Time: 15:35
 */
if (!defined('ACCESS')) {
    exit('Access denied.');
}

class AdminShopCart extends Base
{

    private static $table_name = 'jh_shop_cart';
    // 查询字段
    private static $columns = array('id', 'order_sn', 'userid', 'product_id', 'size', 'color', 'product_nums', 'iddel', 'createtime', 'modifytime');

    public static function getTableName()
    {
        return self::$table_name;
    }


    public static function getShopCartBySn($sn)
    {

        $db = self::__instance();

        $sql = "select p.products_name as products_name,p.products_model as products_model,me.color as products_color,me.size as products_size,me.product_nums as num, (me.product_nums * p.products_special_price) as total_price from " . self::getTableName() . " me," . AdminProducts::getTableName() . " p where me.product_id  = p.products_id and me.order_sn = '$sn'";


        $list = $db->query($sql)->fetchAll();

        return $list;

//        $condition = array('order_sn' => $sn);
//        $db = self::__instance();
//        $rt = $db->select(self::getTableName(), self::$columns, $condition);
//        return $rt;
    }

    public static function update($sn, $data)
    {
        $condition = array('order_sn' => $sn);
        $db = self::__instance();
        $rt = $db->update(self::getTableName(), $data, $condition);
        return $rt;
    }

    public static function delete($sn)
    {
        $condition = array('order_sn' => $sn);
        $db = self::__instance();
        $result = $db->delete(self::getTableName(), $condition);
        return $result;
    }
}




